/*
 *  Arrow
 *
 *  Created by David Giovannini on 1/5/07.
 *  Copyright 2007 Software by Jove. All rights reserved.
 *
 */
 
#ifndef SBJ_Interfaces_IExceptionCounter_h
#define SBJ_Interfaces_IExceptionCounter_h

#include "SBJ/Interfaces/IExceptionObserver.h"

#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>

#include <exception>

namespace SBJ
{

class ExceptionCounter : public IExceptionObserver
{
public:
	typedef boost::shared_ptr< ExceptionCounter > Ptr;

	ExceptionCounter( void );
	
	virtual void onException( const std::exception& exception, const std::string& context = std::string() );
	
	int getExceptionCount( void ) const;

protected:
	mutable boost::mutex m_guard;
	
private:
	int m_exceptions;
	
	virtual void onExceptionSelf( const std::exception& exception, const std::string& context = std::string() ) {}
};

}

#endif